package controller;

import model.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/Product")  //单例
public class ProductController {
    List<Product> products = new ArrayList<>();
    @RequestMapping(value = "add.do",method = RequestMethod.POST)
    public String add_post(Product product, Model model){
        products.add(product);
        model.addAttribute("products",products);
        return "listProducts";
    }
    //跳转到任意页面的方法
    @RequestMapping("getPage.do")
    public String getPage(String page){
        return page;
    }
}
